unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TForm1 = class(TForm)
    Image1: TImage;
    BitBtn1: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  Figure=class
    x, y: integer;
    procedure Draw; virtual; abstract;
  end;

  Circle=class (Figure)
    r, c: integer;
    constructor Create(newC: integer);
    procedure Draw; override;
  end;

  Square=class (Figure)
    a: integer;
    procedure Draw; override;
  end;

  FixedSquare=class (Square)
    constructor Create(newx, newy, newa: integer);
  end;

  RandomSquare=class (Square)
    constructor Create;
  end;

var
  Form1: TForm1;
  f: figure;
implementation

{$R *.dfm}

{ Circle }

  constructor Circle.Create(newC: integer);
  begin
    c:=newC;
    x:=random(Form1.Image1.Width);
    y:=random(Form1.Image1.Height);
    r:=random(100);
  end;

  procedure Circle.Draw;
  begin
    Form1.Image1.Canvas.Brush.Color:=c;
    Form1.image1.canvas.Ellipse(x, y, x+2*r, y-2*r);
    Form1.Image1.Canvas.Brush.Color:=clWhite;
  end;

procedure TForm1.BitBtn1Click(Sender: TObject);
var
  i: integer;
  mass: array [1..100]of  figure;
begin
  for i:=1 to 25 do
  begin
    mass[i]:=Circle.Create(clRed);
    mass[i].Draw;
  end;
  for i:=26 to 50 do
  begin
    mass[i]:=FixedSquare.Create(10*i, 10*i, 50);
    mass[i].Draw;
  end;
  for i:=51 to 100 do
  begin
    mass[i]:=RandomSquare.Create;
    mass[i].Draw;
  end;
end;

{ Square }

procedure Square.Draw;
begin
  form1.Image1.Canvas.Brush.Color:=ClWhite;
  Form1.Image1.Canvas.Rectangle(x, y, x+a, y-a);
end;

{ FixedSquare }

constructor FixedSquare.Create(newx, newy, newa: integer);
begin
    x:=newx;
    y:=newy;
    a:=newa;
end;

{ RandomSquare }

constructor RandomSquare.Create;
begin
    x:=random(Form1.Image1.Width);
    y:=random(Form1.Image1.Height);
    a:=random(100);
end;

end.



